/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OHOS_ROSEN_ANI_PATHITERATOR_H
#define OHOS_ROSEN_ANI_PATHITERATOR_H

#include "ani_drawing_utils.h"
#include "draw/path_iterator.h"

namespace OHOS::Rosen {
namespace Drawing {
class AniPathIterator final {
public:
    explicit AniPathIterator(const Path& path) : pathIterator_(path) {}
    ~AniPathIterator() = default;

    static ani_status AniInit(ani_env *env);

    static void ConstructorWithPath(ani_env* env, ani_object obj, ani_object aniPathObj);

    static ani_object Next(ani_env* env, ani_object obj, ani_object aniPointArray, ani_object aniOffsetObj);

    static ani_boolean HasNext(ani_env* env, ani_object obj);

    static ani_enum_item Peek(ani_env* env, ani_object obj);

    PathIterator& GetPathIterator();

private:
    ani_object OnNext(ani_env* env, ani_object aniPointArray, ani_object aniOffsetObj);
    ani_boolean OnHasNext(ani_env* env);
    ani_enum_item OnPeek(ani_env* env, PathIterator& pathIterator);

    PathVerb NextInternal();
    PathVerb GetReturnVerb(const PathVerb& cachedVerb);

    PathIterator pathIterator_;
    PathVerb verb_ = PathVerb::UNINIT;
    bool done_ = false;
    Point points_[MAX_PAIRS_PATHVERB] = {{0, 0}};
};
} // namespace Drawing
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_ANI_PATHITERATOR_H